﻿using System;
using System.Windows;
using System.Windows.Controls.Primitives;

namespace HobSoft.SoccerBet2014.Client.Controls
{
    public class SlidePopup : Popup
    {
        protected override void OnOpened(EventArgs e)
        {
            var child = (Child as FrameworkElement);
            double actualWidth = this.Width;
            double actualHeight = this.Height;
            if (child != null)
            {
                actualWidth = child.ActualWidth;
                actualHeight = child.ActualHeight;
            }
            if (Placement != PlacementMode.Absolute)
                Placement = PlacementMode.Absolute;
            if (PopupAnimation != PopupAnimation.Slide)
                PopupAnimation = PopupAnimation.Slide;
            this.HorizontalOffset = SystemParameters.WorkArea.Width - actualWidth;
            this.VerticalOffset = SystemParameters.WorkArea.Height / 2 - actualHeight / 2;
            base.OnOpened(e);
        }
    }
}
